#include <iostream>
using std::cout;
using std::endl;
//多重继承时的语法特征
class A{
public:
    A(){
        cout << "A()" << endl;
    }
    ~A(){
        cout << "~A()" << endl;
    }
    void func_a(){
        cout << "func_a" << endl;
    }
private:
    int _a = 10;
};
class B{
public:
    B(){
        cout << "B()" << endl;
    }
    ~B(){
        cout << "~B()" << endl;
    }

    void func_b(){
        cout << "func_b" << endl;
    }
private:
    int _b = 20;
};
class C{
public:
    C(){
        cout << "C()" << endl;
    }
    ~C(){
        cout << "~C()" << endl;
    }
    void func_c(){
        cout << "func_c" << endl;
    }
private:
    int _c = 30;
};
//表示的是公有继承A、B、C
//在这种继承关系下，那么D对象的创建和销毁时如何的
//对应的内存布局是什么样的？？？
class D: 
    public A,
    public B,
    public C{
public:
    D(){
        cout << "D()" << endl;
    }
    ~D(){
        cout << "~D()" << endl;
    }
private:
    int _d = 40;
};
void test(){
    D d;
    d.func_a();
    d.func_b();
    d.func_c();
}

void test2(){
    D d;
    cout << sizeof(A) << endl;//4
    cout << sizeof(B) << endl;//4
    cout << sizeof(C) << endl;//4
    cout << sizeof(D) << endl;//16
}
void test3(){
    D d;
    D * pd = &d;
    //强转为int*指针
    int * pInt = (int *)pd;
    cout << *pInt << endl;
    cout << *(pInt + 1) << endl;
    cout << *(pInt + 2) << endl;
    cout << *(pInt + 3) << endl;
}

int main()
{
    test3();
    return 0;
}

